package com.easylinkin.linkappapi.common.utils.codegenerator.constant;

import static com.easylinkin.linkappapi.common.utils.codegenerator.Config.MODULE_PACKAGE;
import static com.easylinkin.linkappapi.common.utils.codegenerator.Config.PROJECT_PATH;

public class CodeGeneratorConstant {


    public static final String JDBC_DIVER_CLASS_NAME = "com.mysql.cj.jdbc.Driver";
    // 模板位置
    public static final String TEMPLATE_FILE_PATH = PROJECT_PATH + "/src/main/java/com/easylinkin/linkappapi/common/utils/codegenerator/template";
    // java文件路径
    public static final String JAVA_PATH = "/src/main/java";
    // 资源文件路径
    public static final String RESOURCES_PATH = "/src/main/resources";
    // mapper.xml 所在的资源文件路径
    public static final String MAPPER_XML_PATH = "mapper" + MODULE_PACKAGE;

    /**
     * 项目包名
     */
    public static final String PROJECT_PACKAGE = "com.easylinkin.linkappapi";

    /**
     * 生成代码所在的基础包名称，可根据自己公司的项目修改（注意：这个配置修改之后需要手工修改src目录项目默认的包路径，使其保持一致，不然会找不到类）
     */
    public static final String BASE_PACKAGE = PROJECT_PACKAGE + MODULE_PACKAGE;
    /**
     * 生成的entity所在包
     */
    public static final String ENTITY_PACKAGE = BASE_PACKAGE + ".entity";
    /**
     * 生成的Mapper所在包
     */
    public static final String MAPPER_PACKAGE = BASE_PACKAGE + ".mapper";
    /**
     * //生成的Service所在包
     */
    public static final String SERVICE_PACKAGE = BASE_PACKAGE + ".service";
    /**
     * //生成的ServiceImpl所在包
     */
    public static final String SERVICE_IMPL_PACKAGE = SERVICE_PACKAGE + ".impl";


    /**
     * 生成的Controller所在包
     */
    public static final String CONTROLLER_PACKAGE = BASE_PACKAGE + ".controller";

    /**
     * Mapper插件基础接口的完全限定名
     */
    public static final String MAPPER_INTERFACE_REFERENCE = "com.baomidou.mybatisplus.core.mapper.BaseMapper";

    // 生成的entity存放路径
    public static final String PACKAGE_ENTITY_PACKAGE = packageConvertPath(ENTITY_PACKAGE);
    // 生成的mapper存放路径
    public static final String PACKAGE_MAPPER_PACKAGE = packageConvertPath(MAPPER_PACKAGE);
    // 生成的Service存放路径
    public static final String PACKAGE_PATH_SERVICE = packageConvertPath(SERVICE_PACKAGE);
    // 生成的Service实现存放路径
    public static final String PACKAGE_PATH_SERVICE_IMPL = packageConvertPath(SERVICE_IMPL_PACKAGE);
    // 生成的Controller存放路径
    public static final String PACKAGE_PATH_CONTROLLER = packageConvertPath(CONTROLLER_PACKAGE);


    public static String packageConvertPath(String packageName) {
        return String.format("/%s/", packageName.contains(".") ? packageName.replaceAll("\\.", "/") : packageName);
    }
}
